<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>
							请选择店铺：<select   name="shopId" id="shopId">
								<option value="">请选择店铺</option>
							</select>

						</li>
						<li>
							产品：<select   name="enterProductId" id="enterProductId">
							<option value="">请选择产品</option>
						</select>
						</li>
						<li>
						<li>
							订单编号：<input type="text" name="formNum" id="formNum"/>
						</li>
						</li>
						<li>
							审核状态：<select   name="formStatus" id="formStatus">
							<option value="">请选择审核状态</option>
							<option value="1">未审核</option>
							<option value="2">已审核</option>
							</select>
						</li>
						<li class="select-time">
							<label>录入时间： </label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="enter:enter:add">-->
				<!--<i class="fa fa-plus"></i> 录入-->
			<!--</a>-->
			<a class="btn btn-primary " onclick="checkAllEnterForm()" shiro:hasPermission="depot:depot:check">
				<i class="fa fa-check"></i> 审核
			</a>
			<!--<a class="btn btn-primary " onclick="checkAllEnterForm()" shiro:hasPermission="enter:enter:checkAll">-->
				<!--<i class="fa fa-check"></i> 审核-->
			<!--</a>-->
			<a class="btn btn-warning" onclick="exportDepot()" shiro:hasPermission="depot:depot:exportExcel">
				<i class="fa fa-download"></i> 导出
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">
    // var editFlag = [[${@permission.hasPermi('enter:enter:edit')}]];
    // var removeFlag = [[${@permission.hasPermi('enter:enter:remove')}]];
    var prefix = ctx + "depot/depot";
    var datas = [[${@dict.getType('sys_review_state')}]];


    $(function () {
        getAllProduct()
        getAllDept()

        // getAllEnterUser()
    })

function exportDepot(){

    window.location.href =prefix+'/exportExcel?enterProductId='+$("#enterProductId").val()+"&formStatus="+$("#formStatus").val()+"&beginTime="+$("#startTime").val()+"&endTime="+$("#endTime").val()+
	"&shopId="+$("#shopId").val()+"&formNum="+$("#formNum").val();
}
    function getAllProduct() {
        $.ajax({
            type: "GET",
            url: ctx +'analysis/analysis/allProduct',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].id+"'>"+data[i].productName + "</opinion>"
                    $("#enterProductId").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }



    // 获取所有的平台信息
    function getAllDept() {
        $.ajax({
            type: "GET",
            url: prefix +'/allShop',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].id+"'>"+data[i].shopName + "</opinion>"
                    $("#shopId").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }

    // // 获取所有的录单员
    // function getAllEnterUser() {
    //     $.ajax({
    //         type: "GET",
    //         url: prefix +'/getUserByRoeId',
    //         async: false,
    //         contentType : 'application/json;charset=utf-8',
    //         traditional:true,
    //         success : function(data) {
    //             for(var i=0;i<data.length;i++){
    //                 var html = "<option value='"+data[i].userId+"'>"+data[i].userName + "</opinion>"
    //                 $("#createBy").append(html);
    //             }
    //         },
    //         error:function(e) {
    //             console.info(e);
    //         }
    //     });
    // }
    $(function() {
        var options = {
            url: prefix + "/list",
            exportUrl: prefix + "/export",
            uniqueId: "id",
            columns: [{
                checkbox:true,
			}
            ,
                {
                    field: 'Number',
                    title: '序号',
                    formatter: function (value, row, index) {
                        return index + 1;
                    },
                },
                {
                    field: 'id',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'createDate',
                    title: '录入时间',
                },
                {
                    field: 'deptName',
                    title: '平台',
                },
                {
                    field: 'shopName',
                    title: '店铺',
                },
                {
                    field: 'productName',
                    title: '产品名称',
                },
                {
                    field: 'formNum',
                    title: '订单号',
                },
                // {
                //     field: 'formStatus',
                //     title: '审核状态',
                // },
                {
                    field: 'formStatus',
                    title: '状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                // {
                //     field: 'orderPrice',
                //     title: '订单金额',
                // },
                // {
                //     field: 'commission',
                //     title: '支出佣金',
                // },
                {
                    field: 'remark',
                    title: '备注',
                },
                ]
        };
        $.table.init(options);
    });



    // // 审核订单信息
    // function checkAllEnterForm() {
    //     var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
    //     alert(rows)
    //     if (rows.length == 0) {
    //         $.modal.alertWarning("请至少选择一条记录");
    //         return;
    //     }
    //     $.modal.confirm("确认要审核选中的" + rows.length + "条数据吗?", function() {
    //         var url = prefix + "/checkAll";
    //         var data = { "ids": rows.join() };
    //         $.operate.submit(url, "post", "json", data);
    //     });
    // }

    // 获取对应的额产品的和录入人员的加新数
	function getNewCustomerCount(value,row,index) {
        var newCustomerCount;
        var beginTime = $("#startTime").val()
        var endTime = $("#endTime").val()
        $.ajax({
            type:"GET",
            url: prefix +'/getNewCoustomerCount',
            data:{
                "createBy":row.userId,
                "productId":row.productId,
				"beginTime":beginTime,
				"endTime":endTime
			},
            contentType: 'application/json;charset=utf-8',
            traditional: true,
            async:false,
            success : function(data){
                newCustomerCount = data;
            }
        });
        return newCustomerCount;
    }
    // 获取对应的额产品的和录入人员的老客户数
	function getOldCoustomerCount(value,row,index) {
        var odlCustomerCount;
        var beginTime = $("#startTime").val()
        var endTime = $("#endTime").val()
        $.ajax({
            type:"GET",
            url: prefix +'/getOldCoustomerCount',
            data:{
                "createBy":row.userId,
                "productId":row.productId,
                "beginTime":beginTime,
                "endTime":endTime
			},
            contentType: 'application/json;charset=utf-8',
            traditional: true,
            async:false,
            success : function(data){
                odlCustomerCount = data;
            }
        });
        return odlCustomerCount;
    }

    // 获取对应的额产品的和录入人员的积分
    function getIntegralCount(value,row,index) {
        var integralCount;
        var beginTime = $("#startTime").val()
        var endTime = $("#endTime").val()

        $.ajax({
            type:"GET",
            url: prefix +'/getIntegralCount',
            data:{
                "createBy":row.userId,
                "productId":row.productId,
                "goodRecord":row.goodRecord,
                "beginTime":beginTime,
                "endTime":endTime
            },
            contentType: 'application/json;charset=utf-8',
            traditional: true,
            async:false,
            success : function(data){
                integralCount = data;
            }
        });
        return integralCount;
    }

    // 审核订单信息
    function checkAllEnterForm() {
        var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要审核选中的" + rows.length + "条数据吗?", function() {
            var url = prefix + "/checkAll";
            var data = { "ids": rows.join() };
            $.operate.submit(url, "post", "json", data);
        });
    }







</script>
</body>
</html>